/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utn.tsb.tej.world_logic;

import csm.uttils.generics.Roster;

/**
 *
 * @author Administrador
 */
public class ObjectiveEliminate extends Objective {

    private Color color;

    public ObjectiveEliminate(int number, Color color) {
        super(number);
        this.color = color;
    }

    public Color getColor() {
        return color;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    /**
     * Checks if the color of the objective exist in the list of players and is not
     * the color of the player that will get it
     * @param players players in game
     * @param player player who will receive the objective
     * @return
     */
    public boolean targetExist(Roster<Player> players, Player player) {
        boolean b = false;
        String playerColor = player.getColor().getCodeRGB();
        String objectiveColor = color.getCodeRGB();
        if (playerColor.compareTo(objectiveColor) != 0) {
            for (int i = 0; i < players.count(); i++) {
                String thisPlayerColor = players.getElementInPosition(i).getColor().getCodeRGB();
                if (thisPlayerColor.compareTo(objectiveColor) == 0) {
                    b = true;
                }
            }
        }
        return b;
    }

    @Override
    public boolean isAccomplished() {
        boolean accomplished = false;
        if (WorldLogicFacade.getPlayerByColor(color.getCodeRGB()) == null) {
            accomplished = true;
        }
        return accomplished;
    }

    public String toString(){
       
        return "Eliminar al jugaodr " + color.toString();
    }
}
